﻿Imports System.Xml
''' <summary>
''' 调整手续部结构
''' </summary>
''' <remarks></remarks>
Public Class clsJustifyStatement
#Region "需要增加预处理和后处理的改写"
    ''' <summary>
    ''' 调整手续部结构
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Sub JustifyProcedureStructure()
        '对于IF条件里面含有四则运算等等的处理
        mProcedureNode.MainSection.JustifySection()
        For Each secNode As clsStatementBlock In mProcedureNode.SectionList
            secNode.JustifySection()
        Next
        '非静态变量，初始值设定
        For Each mData As XmlElement In mDataNode.WorkStorageList
            If mData.GetAttribute("STATIC") = String.Empty And mData.Name = "SINGLEDATA" And mData.GetAttribute("TYPE") <> "PTR" Then
                '非静态，单个数据，非指针
                If mData.GetAttribute("INIT") <> String.Empty Then
                    '有初始值
                    Dim MoveXml As XmlElement = mXmlDocument.CreateElement("MOVE")
                    MoveXml.SetAttribute("SOURCE", mData.GetAttribute("INIT"))
                    MoveXml.SetAttribute("TARGET", mData.GetAttribute("NAME"))
                    mDataNode.AddSingleInit(MoveXml)
                Else
                    '没有初始值
                    Dim InitXml As XmlElement = mXmlDocument.CreateElement("INIT")
                    InitXml.SetAttribute("TARGET", mData.GetAttribute("NAME"))
                    mDataNode.AddSingleInit(InitXml)
                End If
            End If
        Next
    End Sub
    ''' <summary>
    ''' 处理顶层元素
    ''' </summary>
    ''' <param name="strExpress"></param>
    ''' <param name="PreProcess">预处理列表</param>
    ''' <param name="AfterProcess">后处理列表</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function ModifyTopExpress(ByVal strExpress As String, ByVal PreProcess As clsStatementBlock, ByVal AfterProcess As clsStatementBlock) As String
        Dim strFunc As String
        Select Case True
            Case strExpress.StartsWith("ADDR(")
                strFunc = "ADDR"
            Case strExpress.StartsWith("STG(")
                strFunc = "STG"
            Case strExpress.StartsWith("STORAGE(")
                strFunc = "STORAGE"
            Case strExpress.StartsWith("LENGTH(")
                strFunc = "LENGTH"
            Case strExpress.StartsWith("MOD(")
                strFunc = "MOD"
            Case strExpress.StartsWith("SUBSTR(")
                strFunc = "SUBSTR"
            Case Else
                '需要做复杂转换的命令
                strFunc = String.Empty
        End Select
        If strFunc = String.Empty Then
            strExpress = clsJustifyStatement.ModifySubExpress(strExpress, PreProcess, AfterProcess)
        Else
            '最顶层的语句，ADDR这样的命令不做复杂变换,
            strExpress = clsJustifyStatement.ModifySubExpress(strExpress, PreProcess, AfterProcess)
            Dim rtnParament As String = String.Empty
            Dim FunctionXml As XmlElement = PreProcess.SingleStatementList(PreProcess.Count - 1)
            If FunctionXml.GetAttribute("P1") <> String.Empty Then
                rtnParament = FunctionXml.GetAttribute("P1") & ","
            End If
            If FunctionXml.GetAttribute("P2") <> String.Empty Then
                rtnParament &= FunctionXml.GetAttribute("P2") & ","
            End If
            If FunctionXml.GetAttribute("P3") <> String.Empty Then
                rtnParament &= FunctionXml.GetAttribute("P3") & ","
            End If
            If FunctionXml.GetAttribute("P4") <> String.Empty Then
                rtnParament &= FunctionXml.GetAttribute("P4") & ","
            End If
            rtnParament = Mid(rtnParament, 1, rtnParament.Length - 1)
            strExpress = strFunc & "(" & rtnParament & ")"
            '将变为临时变量的函数变回来
            RemoveWorkDataByName(PreProcess.SingleStatementList(PreProcess.Count - 1).GetAttribute("RESULT"))
            PreProcess.SingleStatementList.RemoveAt(PreProcess.Count - 1)
        End If
        Return strExpress
    End Function
    ''' <summary>
    ''' 预处理和后处理语句的追加
    ''' </summary>
    ''' <param name="strExpress"></param>
    ''' <param name="PreProcess">预处理列表</param>
    ''' <param name="AfterProcess">后处理列表</param>
    ''' <returns>变换后的变量</returns>
    ''' <remarks>第一级改写的话，一定会产生预处理语句或者后处理语句
    ''' </remarks>
    Public Shared Function ModifySubExpress(ByVal strExpress As String, ByVal PreProcess As clsStatementBlock, ByVal AfterProcess As clsStatementBlock) As String
        Dim FunctionWords As List(Of String)
        Dim conditionWords As List(Of String) = GetSyntaxToken(strExpress)
        Dim rtnExpress As String
        strExpress = strExpress.Trim
        rtnExpress = strExpress
        Select Case True
            Case strExpress.StartsWith("VERIFY(")
                'VERIFY
                FunctionWords = GetMethodNameAndArgs(conditionWords(0))
                '暂时处理 VERIFY(A,B) = C 的情况
                rtnExpress = "WK_PLI_I" & WK_COUNT
                mDataNode.WorkList.Add(getWorkDataFIXED_DEC(9))
                '将VERIFY的预处理放入预处理
                Dim rtnXMLList As List(Of XmlElement)
                If FunctionWords.Count = 3 Then
                    'VERIFY(arg1,arg2) OPEN PLI
                    rtnXMLList = GetVERIFY(ModifySubExpress(FunctionWords(1), PreProcess, AfterProcess), _
                                          ModifySubExpress(FunctionWords(2), PreProcess, AfterProcess), _
                                          String.Empty, rtnExpress)
                Else
                    'VERIFY(arg1,arg2,arg3) Enterprise PL/I for z/OS Version 3
                    rtnXMLList = GetVERIFY(ModifySubExpress(FunctionWords(1), PreProcess, AfterProcess), _
                                          ModifySubExpress(FunctionWords(2), PreProcess, AfterProcess), _
                                          ModifySubExpress(FunctionWords(3), PreProcess, AfterProcess), _
                                          rtnExpress)
                End If
                For Each oprxml As XmlElement In rtnXMLList
                    PreProcess.AddOperation(oprxml)
                Next
            Case strExpress.StartsWith("INDEX(")
                'INDEX
                FunctionWords = GetMethodNameAndArgs(conditionWords(0))
                '暂时处理 INDEX(A,B) = C 的情况
                rtnExpress = "WK_PLI_I" & WK_COUNT
                mDataNode.WorkList.Add(getWorkDataFIXED_DEC(9))
                '将VERIFY的预处理放入预处理
                Dim rtnXMLList As List(Of XmlElement)
                If FunctionWords.Count = 3 Then
                    'INDEX(arg1,arg2) OPEN PLI
                    rtnXMLList = GetINDEX(ModifySubExpress(FunctionWords(1), PreProcess, AfterProcess), _
                                          ModifySubExpress(FunctionWords(2), PreProcess, AfterProcess), _
                                          String.Empty, rtnExpress)
                Else
                    'INDEX(arg1,arg2,arg3) Enterprise PL/I for z/OS Version 3
                    rtnXMLList = GetINDEX(ModifySubExpress(FunctionWords(1), PreProcess, AfterProcess), _
                                          ModifySubExpress(FunctionWords(2), PreProcess, AfterProcess), _
                                          ModifySubExpress(FunctionWords(3), PreProcess, AfterProcess), _
                                          rtnExpress)
                End If
                For Each oprxml As XmlElement In rtnXMLList
                    PreProcess.AddOperation(oprxml)
                Next
            Case strExpress.StartsWith("TRANSLATE(")
                'TRANSLATE
                FunctionWords = GetMethodNameAndArgs(conditionWords(0))
                '暂时处理 TRANSLATE(A,B) = C 的情况
                rtnExpress = "WK_PLI_I" & WK_COUNT
                mDataNode.WorkList.Add(getWorkDataFIXED_DEC(9))
                '将TRANSLATE的预处理放入预处理
                Dim rtnXMLList As List(Of XmlElement)
                If FunctionWords.Count = 4 Then
                    'TRANSLATE(arg1,arg2) OPEN PLI
                    rtnXMLList = GetTranslate(ModifySubExpress(FunctionWords(1), PreProcess, AfterProcess), _
                                              ModifySubExpress(FunctionWords(2), PreProcess, AfterProcess), _
                                              ModifySubExpress(FunctionWords(3), PreProcess, AfterProcess), _
                                              rtnExpress)
                Else
                    'TRANSLATE(arg1,arg2,arg3) Enterprise PL/I for z/OS Version 3
                    rtnXMLList = GetTranslate(ModifySubExpress(FunctionWords(1), PreProcess, AfterProcess), _
                                              ModifySubExpress(FunctionWords(2), PreProcess, AfterProcess), _
                                              String.Empty, rtnExpress)
                End If
                For Each oprxml As XmlElement In rtnXMLList
                    PreProcess.AddOperation(oprxml)
                Next
            Case strExpress.StartsWith("ROUND(")
                If strExpress.StartsWith("ROUND(ADD(") Or
                   strExpress.StartsWith("ROUND(SUBTRACT(") Or
                   strExpress.StartsWith("ROUND(MULTIPLY(") Or
                   strExpress.StartsWith("ROUND(DIVIDE(") Then
                    '将ROUND(ADD( 为带有ROUNDED的ADD(
                    strExpress = Mid(strExpress, 7, strExpress.Length - 9)
                    Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strExpress)
                    Dim FUNCXml As XmlElement = mXmlDocument.CreateElement(Mid(strExpress, 1, strExpress.IndexOf("(")))
                    FUNCXml.SetAttribute("P1", ModifySubExpress(strSubStrList(1), PreProcess, AfterProcess))
                    FUNCXml.SetAttribute("P2", ModifySubExpress(strSubStrList(2), PreProcess, AfterProcess))
                    FUNCXml.SetAttribute("P3", strSubStrList(4) - 1)
                    FUNCXml.SetAttribute("ROUNDED", True)
                    rtnExpress = "WK_PLI_I" & WK_COUNT
                    FUNCXml.SetAttribute("RESULT", rtnExpress)
                    mDataNode.WorkList.Add(getWorkDataFIXED_DEC(strSubStrList(3)))
                    PreProcess.AddOperation(FUNCXml)
                Else
                    'ROUND(Express,0)
                    '换成COMPUTE Target ROUNDED = Express来处理
                    Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strExpress)
                    Dim COMPUTEXml As XmlElement = mXmlDocument.CreateElement("COMPUTE")
                    rtnExpress = "WK_PLI_I" & WK_COUNT
                    '正确的写法应该是操作数的整数位数，操作数的小数位数+1
                    mDataNode.WorkList.Add(getWorkDataFIXED_DEC(15, strSubStrList(2)))
                    COMPUTEXml.SetAttribute("FORMULATE", GetFormalExpress(strSubStrList(1), PreProcess, AfterProcess))
                    COMPUTEXml.SetAttribute("TARGET", rtnExpress)
                    COMPUTEXml.SetAttribute("ROUNDED", True)
                    COMPUTEXml = clsStatementCompute.JustifyCompute(COMPUTEXml, PreProcess, AfterProcess)
                    PreProcess.AddOperation(COMPUTEXml)
                End If
            Case strExpress.StartsWith("DIVIDE("), _
                 strExpress.StartsWith("ADD("), _
                 strExpress.StartsWith("SUBTRACT("), _
                 strExpress.StartsWith("MULTIPLY(")
                'XXXX(Express1,Express2，Express3，Express4)
                Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strExpress)
                Dim FUNCXml As XmlElement = mXmlDocument.CreateElement(Mid(strExpress, 1, strExpress.IndexOf("(")))
                FUNCXml.SetAttribute("P1", ModifySubExpress(strSubStrList(1), PreProcess, AfterProcess))
                FUNCXml.SetAttribute("P2", ModifySubExpress(strSubStrList(2), PreProcess, AfterProcess))
                FUNCXml.SetAttribute("P3", strSubStrList(3))
                '这四个函数只是做截断处理，不做四舍五入处理
                If strSubStrList.Count = 5 Then
                    rtnExpress = "WK_PLI_I" & WK_COUNT
                    mDataNode.WorkList.Add(getWorkDataFIXED_DEC(strSubStrList(3), strSubStrList(4)))
                    FUNCXml.SetAttribute("RESULT", rtnExpress)
                    FUNCXml.SetAttribute("P4", strSubStrList(4))
                    PreProcess.AddOperation(FUNCXml)
                Else
                    rtnExpress = "WK_PLI_I" & WK_COUNT
                    mDataNode.WorkList.Add(getWorkDataFIXED_DEC(strSubStrList(3)))
                    FUNCXml.SetAttribute("RESULT", rtnExpress)
                    FUNCXml.SetAttribute("P4", strSubStrList(4))
                    PreProcess.AddOperation(FUNCXml)
                End If
            Case strExpress = "TIME" Or strExpress = "TIME()"
                'ACCEPT语句的TIME不会被送到这个方法中
                Dim AcceptXml As Xml.XmlElement = mXmlDocument.CreateElement("ACCEPT")
                rtnExpress = "WK_PLI_" & WK_COUNT
                getWorkDataFIXED_DEC(9)
                AcceptXml.SetAttribute("TARGET", rtnExpress)
                AcceptXml.SetAttribute("FUNCTION", "TIME")
                PreProcess.AddOperation(AcceptXml)
            Case strExpress = "DATE" Or strExpress = "DATE()"
                'ACCEPT语句的DATE不会被送到这个方法中
                Dim AcceptXml As Xml.XmlElement = mXmlDocument.CreateElement("ACCEPT")
                rtnExpress = "WK_PLI_" & WK_COUNT
                getWorkDataFIXED_DEC(9)
                AcceptXml.SetAttribute("TARGET", rtnExpress)
                AcceptXml.SetAttribute("FUNCTION", "DATE")
                PreProcess.AddOperation(AcceptXml)
            Case strExpress = "DATETIME" Or strExpress = "DATETIME()"
                'ACCEPT语句的DATE不会被送到这个方法中
                Dim AcceptXml As Xml.XmlElement = mXmlDocument.CreateElement("ACCEPT")
                rtnExpress = "WK_PLI_" & WK_COUNT
                getWorkDataFIXED_DEC(9)
                AcceptXml.SetAttribute("TARGET", rtnExpress)
                AcceptXml.SetAttribute("FUNCTION", "DATETIME")
                PreProcess.AddOperation(AcceptXml)
            Case strExpress = "WEEKDAY" Or strExpress = "WEEKDAY()"
                '这个版本不对应WEEKDAY(X)的形式
                Dim AcceptXml As Xml.XmlElement = mXmlDocument.CreateElement("ACCEPT")
                rtnExpress = "WK_PLI_" & WK_COUNT
                getWorkDataFIXED_DEC(9)
                AcceptXml.SetAttribute("TARGET", rtnExpress)
                AcceptXml.SetAttribute("FUNCTION", "DAY-OF-WEEK")
                PreProcess.AddOperation(AcceptXml)
                'PL1和COBOL的星期计算方法不同。这里需要进行修正
                Dim mIFNode As New IFNode
                Dim mConditionNode As New ConditionNode("WK_PLI_" & WK_COUNT & " = 7")
                mIFNode.IFCondition = mConditionNode
                Dim mMoveNode As XmlElement = mXmlDocument.CreateElement("MOVE")
                mMoveNode = clsStatementMove.GetXmlElement("ZERO", "WK_PLI_" & WK_COUNT)
                mIFNode.TrueOperationList.AddOperation(mMoveNode)
                Dim mComputeNode As XmlElement = mXmlDocument.CreateElement("COMPUTE")
                mComputeNode.SetAttribute("TARGET", "WK_PLI_" & WK_COUNT)
                mComputeNode.SetAttribute("FORMULATE", "WK_PLI_" & WK_COUNT & " + 1")
                mIFNode.FalseOperationList.AddOperation(mComputeNode)
                AfterProcess.AddIF(mIFNode)
            Case strExpress = "PLIRETV" Or strExpress = "PLIRETV()"
                '获得PLI返回值的函数
                rtnExpress = "RETURN_CODE"
            Case strExpress.StartsWith("STRING(")
                'STRING(Express)
                '这个函数COBOL可能不需要
                Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strExpress)
                Dim STRINGXml As XmlElement = mXmlDocument.CreateElement("FUNCTION")
                STRINGXml.SetAttribute("P1", ModifySubExpress(strSubStrList(1), PreProcess, AfterProcess))
                rtnExpress = "WK_PLI_I" & WK_COUNT
                STRINGXml.SetAttribute("TARGET", rtnExpress)
                STRINGXml.SetAttribute("RESULT", rtnExpress)
                PreProcess.AddOperation(STRINGXml)
                mDataNode.WorkList.Add(getWorkDataCHAR(15))
            Case strExpress.StartsWith("STG(") Or strExpress.StartsWith("STORAGE(") Or strExpress.StartsWith("LENGTH(")
                'STG的判断
                Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strExpress)
                Dim STGXml As XmlElement = mXmlDocument.CreateElement("FUNCTION")
                STGXml.SetAttribute("NAME", "STG")
                STGXml.SetAttribute("P1", ModifySubExpress(strSubStrList(1), PreProcess, AfterProcess))
                rtnExpress = "WK_PLI_I" & WK_COUNT
                STGXml.SetAttribute("RESULT", rtnExpress)
                PreProcess.AddOperation(STGXml)
            Case strExpress.StartsWith("ADDR(")
                'ADDR的判断
                Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strExpress)
                Dim ADDRXml As XmlElement = mXmlDocument.CreateElement("FUNCTION")
                ADDRXml.SetAttribute("NAME", "ADDR")
                ADDRXml.SetAttribute("P1", ModifySubExpress(strSubStrList(1), PreProcess, AfterProcess))
                rtnExpress = "WK_PLI_I" & WK_COUNT
                ADDRXml.SetAttribute("RESULT", rtnExpress)
                PreProcess.AddOperation(ADDRXml)
            Case strExpress.StartsWith("MOD(")
                'MOD的判断
                Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strExpress)
                Dim ModXml As XmlElement = mXmlDocument.CreateElement("FUNCTION")
                ModXml.SetAttribute("NAME", "MOD")
                ModXml.SetAttribute("P1", ModifySubExpress(strSubStrList(1), PreProcess, AfterProcess))
                ModXml.SetAttribute("P2", ModifySubExpress(strSubStrList(2), PreProcess, AfterProcess))
                rtnExpress = "WK_PLI_I" & WK_COUNT
                mDataNode.WorkList.Add(getWorkDataCHAR(255))
                ModXml.SetAttribute("RESULT", rtnExpress)
                PreProcess.AddOperation(ModXml)
            Case strExpress.StartsWith("SUBSTR(")
                'SUBSTR的判断
                Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strExpress)
                Dim SUBSTRXml As XmlElement = mXmlDocument.CreateElement("FUNCTION")
                SUBSTRXml.SetAttribute("NAME", "SUBSTR")
                Select Case strSubStrList.Count
                    Case 3
                        SUBSTRXml.SetAttribute("P1", ModifySubExpress(strSubStrList(1), PreProcess, AfterProcess))
                        SUBSTRXml.SetAttribute("P2", ModifySubExpress(strSubStrList(2), PreProcess, AfterProcess))
                    Case 4
                        SUBSTRXml.SetAttribute("P1", ModifySubExpress(strSubStrList(1), PreProcess, AfterProcess))
                        SUBSTRXml.SetAttribute("P2", ModifySubExpress(strSubStrList(2), PreProcess, AfterProcess))
                        SUBSTRXml.SetAttribute("P3", ModifySubExpress(strSubStrList(3), PreProcess, AfterProcess))
                End Select
                rtnExpress = "WK_PLI_I" & WK_COUNT
                mDataNode.WorkList.Add(getWorkDataCHAR(255))
                SUBSTRXml.SetAttribute("RESULT", rtnExpress)
                PreProcess.AddOperation(SUBSTRXml)
            Case IsFormulate(strExpress)
                '计算式的情况
                Dim COMPUTEXml As Xml.XmlElement = mXmlDocument.CreateElement("COMPUTE")
                rtnExpress = "WK_PLI_I" & WK_COUNT
                COMPUTEXml.SetAttribute("TARGET", rtnExpress)
                mDataNode.WorkList.Add(getWorkDataFIXED_DEC(9))
                COMPUTEXml.SetAttribute("FORMULATE", GetFormalExpress(strExpress, PreProcess, AfterProcess))
                PreProcess.AddOperation(COMPUTEXml)
            Case strExpress.Contains("||")
                '连字符
                Dim stringSeparators() As String = {"||"}
                Dim stringGroup As String() = strExpress.Split(stringSeparators, StringSplitOptions.None)
                Dim strwords As List(Of String) = GetSyntaxToken(strExpress)
                Dim STRINGXml As Xml.XmlElement = mXmlDocument.CreateElement("STRING")
                STRINGXml.SetAttribute("COMMENT", "*Pls Modify the length of WK-VAL")
                For Each Substr As String In stringGroup
                    Dim SubStringXml As Xml.XmlElement = mXmlDocument.CreateElement("SUBSTRING")
                    SubStringXml.SetAttribute("TEXT", ModifySubExpress(Substr, PreProcess, AfterProcess))
                    STRINGXml.AppendChild(SubStringXml)
                Next
                rtnExpress = "WK_PLI_I" & WK_COUNT
                STRINGXml.SetAttribute("TARGET", rtnExpress)
                PreProcess.AddOperation(STRINGXml)
                mDataNode.WorkList.Add(getWorkDataCHAR(255))
            Case strExpress.Contains("->")
                'Locator
                GetLocatorList(strExpress, PreProcess, AfterProcess)
                rtnExpress = Mid(rtnExpress, rtnExpress.IndexOf("->") + 3)
            Case Else
                'A(B).C(D) -> A(B)   C(D)
                'A.B(C,D.E(F))可能存在，所以不能简单的时候Split方法
                'A.B(C,D.E(F)) -> A B(C,D.E(F))
                Dim DotArray As String()
                DotArray = GetSubLinesBySplitMark(strExpress, ".", SplitStyle.NoSplitMark).ToArray
                If DotArray.Length > 1 Then
                    Dim NewArray As New List(Of String)
                    For Each DotSub As String In DotArray
                        'A.DATE的过滤
                        If KeyWordList.ContainsKey(DotSub) Then
                            NewArray.Add(DotSub)
                        Else
                            NewArray.Add(ModifySubExpress(DotSub, PreProcess, AfterProcess))
                        End If
                    Next
                    rtnExpress = Join(NewArray.ToArray, ".")
                Else
                    If strExpress.Contains("(") And strExpress.EndsWith(")") Then
                        'FUN(A,B)的整理
                        'A,B,C 这样的字符串也会返回 A B C 这样的文字列
                        '但是似乎A,B,C 这样的字符串没有理由会单独出现
                        Dim FunctionList As New List(Of String)
                        FunctionList = GetMethodNameAndArgs(strExpress)
                        If FunctionList(0) <> String.Empty Then
                            rtnExpress = ""
                            Dim HasChange As Boolean = False
                            Dim strNew As String
                            '对于非1为下标的数组的修正
                            Dim deleta As SByte
                            deleta = 0
                            If mDataNode.UnderBoundNotFrom1.ContainsKey(FunctionList(0)) Then
                                deleta = 1 - mDataNode.UnderBoundNotFrom1(FunctionList(0))
                            End If
                            For i As Integer = 0 To FunctionList.Count - 1
                                Select Case i
                                    Case 0
                                        'T(A,B... 第一个T应该没有理由需要变换
                                        '如果T需要变换的话，请注意是不是TIME，DATE等关键字
                                        rtnExpress = FunctionList(0) & "("
                                    Case FunctionList.Count - 1
                                        '最后一个元素
                                        If deleta <> 0 Then
                                            If IsNumeric(FunctionList(i)) Then
                                                strNew = FunctionList(i) + deleta
                                                HasChange = False
                                            Else
                                                If deleta = 1 Then
                                                    strNew = ModifySubExpress(FunctionList(i) & " + 1", PreProcess, AfterProcess)
                                                Else
                                                    strNew = ModifySubExpress(FunctionList(i) & " - " & -(deleta), PreProcess, AfterProcess)
                                                End If
                                                HasChange = True
                                            End If
                                        Else
                                            strNew = ModifySubExpress(FunctionList(i), PreProcess, AfterProcess)
                                            If FunctionList(i) <> strNew Then HasChange = True
                                        End If
                                        rtnExpress &= strNew & ")"
                                    Case Else
                                        '中间元素
                                        If deleta <> 0 Then
                                            If IsNumeric(FunctionList(i)) Then
                                                strNew = FunctionList(i) + deleta
                                                HasChange = False
                                            Else
                                                If deleta = 1 Then
                                                    strNew = ModifySubExpress(FunctionList(i) & " + 1", PreProcess, AfterProcess)
                                                Else
                                                    strNew = ModifySubExpress(FunctionList(i) & " - " & -(deleta), PreProcess, AfterProcess)
                                                End If
                                                HasChange = True
                                            End If
                                        Else
                                            strNew = ModifySubExpress(FunctionList(i), PreProcess, AfterProcess)
                                            If FunctionList(i) <> strNew Then HasChange = True
                                        End If
                                        rtnExpress &= strNew & ","
                                End Select
                            Next
                            If HasChange Then
                                '如果发生了变换的情况 
                                Dim MOVEXml As Xml.XmlElement = mXmlDocument.CreateElement("MOVE")
                                MOVEXml.SetAttribute("SOURCE", rtnExpress)
                                rtnExpress = "WK_PLI_I" & WK_COUNT
                                mDataNode.WorkList.Add(getWorkDataCHAR(255))
                                MOVEXml.SetAttribute("TARGET", rtnExpress)
                                PreProcess.AddOperation(MOVEXml)
                            End If
                        End If
                    End If
                End If
        End Select
        Return rtnExpress
    End Function
    ''' <summary>
    ''' 获取文字列的计算式
    ''' </summary>
    ''' <param name="strExpress"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetFormulate(ByVal strExpress As String) As String
        Dim IsStartWithQuote As Boolean = False
        strExpress = strExpress.Trim
        Dim QuoteLV As Byte = 0
        Dim intStart As Integer = 1
        Dim SingleChar As Char = String.Empty
        If strExpress.StartsWith("(") And strExpress.EndsWith(")") Then
            '如果以 "(" 开头,以 ")" 结尾,并且这首尾两个括号能够匹配的话,去除这个两个括号
            For iLength As Integer = 1 To strExpress.Length
                SingleChar = Mid(strExpress, iLength, 1)
                Select Case SingleChar
                    Case "("
                        QuoteLV += 1
                    Case ")"
                        QuoteLV -= 1
                        If QuoteLV = 0 Then
                            If iLength = strExpress.Length Then
                                IsStartWithQuote = True
                                strExpress = Mid(strExpress, 2, strExpress.Length - 2)
                            Else
                                IsStartWithQuote = False
                                Exit For
                            End If
                        End If
                End Select
            Next
        End If
        If InStr(strExpress, "+") + InStr(strExpress, "-") + InStr(strExpress, "*") + InStr(strExpress, "/") > 0 Then
            For iLength As Integer = 1 To strExpress.Length
                SingleChar = Mid(strExpress, iLength, 1)
                Select Case SingleChar
                    Case "("
                        QuoteLV += 1
                    Case ")"
                        QuoteLV -= 1
                    Case "+", "-", "*", "/"
                        If QuoteLV = 0 Then
                            If IsStartWithQuote Then
                                '恢复这两个括号
                                Return "(" & GetFormulate(Mid(strExpress, 1, iLength - 1).Trim) & Space(1) & SingleChar & Space(1) & GetFormulate(Mid(strExpress, iLength + 1).Trim) & ")"
                            Else
                                Return GetFormulate(Mid(strExpress, 1, iLength - 1).Trim) & Space(1) & SingleChar & Space(1) & GetFormulate(Mid(strExpress, iLength + 1).Trim)
                            End If
                        End If
                End Select
            Next
        End If
        Return strExpress.Trim
    End Function
    ''' <summary>
    ''' 获得计算式的调整结构
    ''' </summary>
    ''' <param name="strExpress"></param>
    ''' <param name="preProcess"></param>
    ''' <param name="AfterProcess"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetFormalExpress(ByVal strExpress As String, ByVal preProcess As clsStatementBlock, ByVal AfterProcess As clsStatementBlock)
        Dim NewWordList As New List(Of String)
        strExpress = GetFormulate(strExpress)
        Dim strWordList As List(Of String) = GetSyntaxToken(strExpress)
        If strWordList.Count = 1 Then
            Return ModifySubExpress(strExpress, preProcess, AfterProcess)
        Else
            For Each strSub As String In strWordList
                NewWordList.Add(GetFormalExpress(strSub, preProcess, AfterProcess))
            Next
            Return Join(NewWordList.ToArray)
        End If
    End Function
    ''' <summary>
    ''' 拼接出VERIFY的预处理节点
    ''' </summary>
    ''' <param name="arg1">VERIFY(arg1,arg2)</param>
    ''' <param name="arg2">VERIFY(arg1,arg2)</param>
    ''' <param name="rtnExpress">将这个结果放在中间变量中</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetVERIFY(ByVal arg1 As String, ByVal arg2 As String, ByVal arg3 As String, ByVal rtnExpress As String) As List(Of XmlElement)
        Dim oprlist As New List(Of XmlElement)
        Dim MoveXmlArg1 As Xml.XmlElement
        MoveXmlArg1 = mXmlDocument.CreateElement("MOVE")
        If arg3 = String.Empty Then
            '没有第三参数来指定开始位置的时候
            MoveXmlArg1.SetAttribute("SOURCE", arg1)
        Else
            '有第三参数来指定开始位置的时候
            Dim ComputeXml As XmlElement = mXmlDocument.CreateElement("COMPUTE")
            ComputeXml.SetAttribute("TARGET", "WK_PLI_" & WK_COUNT)
            getWorkDataFIXED_DEC(9)
            ComputeXml.SetAttribute("FORMULATE", "STG(" & arg1 & ")-" & arg3 & "+1")
            oprlist.Add(ComputeXml)
            MoveXmlArg1.SetAttribute("SOURCE", "SUBSTR(" & arg1 & "," & arg3 & "," & "WK_PLI_" & WK_COUNT & ")")
        End If
        MoveXmlArg1.SetAttribute("TARGET", "VERIFY_DATA")
        oprlist.Add(MoveXmlArg1)

        Dim MoveXmlArg2 As Xml.XmlElement
        MoveXmlArg2 = mXmlDocument.CreateElement("MOVE")
        MoveXmlArg2.SetAttribute("SOURCE", arg2)
        MoveXmlArg2.SetAttribute("TARGET", "VERIFY_TEST")
        oprlist.Add(MoveXmlArg2)

        Dim MoveXmlArg1Length As Xml.XmlElement
        MoveXmlArg1Length = mXmlDocument.CreateElement("MOVE")
        MoveXmlArg1Length.SetAttribute("SOURCE", "STG(" & arg1 & ")")
        MoveXmlArg1Length.SetAttribute("TARGET", "VERIFY_DATALEN")
        oprlist.Add(MoveXmlArg1Length)

        Dim MoveXmlArg2Length As Xml.XmlElement
        MoveXmlArg2Length = mXmlDocument.CreateElement("MOVE")
        '需要判断arg2是否为常数，例如在数字检测，字母检测的情况下
        If arg2.StartsWith("'") And arg2.EndsWith("'") Then
            '常数的情况下
            MoveXmlArg2Length.SetAttribute("SOURCE", arg2.Length - 2)
        Else
            '变量的情况下
            MoveXmlArg2Length.SetAttribute("SOURCE", "STG(" & arg2 & ")")
        End If
        MoveXmlArg2Length.SetAttribute("TARGET", "VERIFY_TESTLEN")
        oprlist.Add(MoveXmlArg2Length)

        Dim Callxml As Xml.XmlElement
        Callxml = mXmlDocument.CreateElement("CALL")
        Callxml.SetAttribute("METHOD", "VERIFY")
        Callxml.SetAttribute("TYPE", "Perform")
        oprlist.Add(Callxml)

        Dim MoveXmlResult As Xml.XmlElement
        MoveXmlResult = mXmlDocument.CreateElement("MOVE")
        MoveXmlResult.SetAttribute("SOURCE", "VERIFY_RESULT")
        MoveXmlResult.SetAttribute("TARGET", rtnExpress)
        oprlist.Add(MoveXmlResult)

        Return oprlist
    End Function
    ''' <summary>
    ''' 拼接出INDEX的预处理节点
    ''' </summary>
    ''' <param name="arg1">INDEX(arg1,arg2)</param>
    ''' <param name="arg2">INDEX(arg1,arg2)</param>
    ''' <param name="rtnExpress">将这个结果放在中间变量中</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetINDEX(ByVal arg1 As String, ByVal arg2 As String, ByVal arg3 As String, ByVal rtnExpress As String) As List(Of XmlElement)
        Dim oprlist As New List(Of XmlElement)
        Dim MoveXmlArg1 As XmlElement
        MoveXmlArg1 = mXmlDocument.CreateElement("MOVE")

        If arg3 = String.Empty Then
            '没有第三参数来指定开始位置的时候
            MoveXmlArg1.SetAttribute("SOURCE", arg1)
        Else
            '有第三参数来指定开始位置的时候
            Dim ComputeXml As XmlElement = mXmlDocument.CreateElement("COMPUTE")
            ComputeXml.SetAttribute("TARGET", "WK_PLI_" & WK_COUNT)
            getWorkDataFIXED_DEC(9)
            ComputeXml.SetAttribute("FORMULATE", "STG(" & arg1 & ")-" & arg3 & "+1")
            oprlist.Add(ComputeXml)
            MoveXmlArg1.SetAttribute("SOURCE", "SUBSTR(" & arg1 & "," & arg3 & "," & "WK_PLI_" & WK_COUNT & ")")
        End If
        MoveXmlArg1.SetAttribute("TARGET", "INDEX_DATA")
        oprlist.Add(MoveXmlArg1)

        Dim MoveXmlArg2 As Xml.XmlElement
        MoveXmlArg2 = mXmlDocument.CreateElement("MOVE")
        MoveXmlArg2.SetAttribute("SOURCE", arg2)
        MoveXmlArg2.SetAttribute("TARGET", "INDEX_TEST")
        oprlist.Add(MoveXmlArg2)

        Dim MoveXmlArg2Length As Xml.XmlElement
        MoveXmlArg2Length = mXmlDocument.CreateElement("MOVE")
        '需要判断arg2是否为常数，例如在数字检测，字母检测的情况下
        If arg2.StartsWith("'") And arg2.EndsWith("'") Then
            '常数的情况下
            MoveXmlArg2Length.SetAttribute("SOURCE", arg2.Length - 2)
        Else
            '变量的情况下
            MoveXmlArg2Length.SetAttribute("SOURCE", "STG(" & arg2 & ")")
        End If
        MoveXmlArg2Length.SetAttribute("TARGET", "INDEX_TESTLEN")
        oprlist.Add(MoveXmlArg2Length)


        Dim Callxml As Xml.XmlElement
        Callxml = mXmlDocument.CreateElement("CALL")
        Callxml.SetAttribute("METHOD", "INDEX")
        Callxml.SetAttribute("TYPE", "Perform")
        oprlist.Add(Callxml)

        Dim MoveXmlResult As Xml.XmlElement
        MoveXmlResult = mXmlDocument.CreateElement("MOVE")
        MoveXmlResult.SetAttribute("SOURCE", "INDEX_RESULT")
        MoveXmlResult.SetAttribute("TARGET", rtnExpress)
        oprlist.Add(MoveXmlResult)

        Return oprlist
    End Function
    ''' <summary>
    ''' 拼接出TRANSLATE的预处理节点
    ''' </summary>
    ''' <param name="arg1">Translate(arg1,arg2,arg3)</param>
    ''' <param name="arg2">Translate(arg1,arg2,arg3)</param>
    ''' <param name="arg3">Translate(arg1,arg2,arg3)</param>
    ''' <param name="rtnExpress">将这个结果放在中间变量中</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetTranslate(ByVal arg1 As String, ByVal arg2 As String, ByVal arg3 As String, ByVal rtnExpress As String) As List(Of XmlElement)
        Dim oprlist As New List(Of XmlElement)
        Dim MoveXmlArg1 As Xml.XmlElement
        MoveXmlArg1 = mXmlDocument.CreateElement("MOVE")
        MoveXmlArg1.SetAttribute("SOURCE", arg1)
        MoveXmlArg1.SetAttribute("TARGET", "TRANSLATE_DATA")
        oprlist.Add(MoveXmlArg1)


        Dim MoveXmlArg4 As Xml.XmlElement
        MoveXmlArg4 = mXmlDocument.CreateElement("MOVE")
        MoveXmlArg4.SetAttribute("SOURCE", "STG(" & arg1 & ")")
        MoveXmlArg4.SetAttribute("TARGET", "TRANSLATE_DATALEN")
        oprlist.Add(MoveXmlArg4)

        Dim MoveXmlArg2 As Xml.XmlElement
        MoveXmlArg2 = mXmlDocument.CreateElement("MOVE")
        MoveXmlArg2.SetAttribute("SOURCE", arg2)
        MoveXmlArg2.SetAttribute("TARGET", "TRANSLATE_TO")
        oprlist.Add(MoveXmlArg2)

        Dim MoveXmlArg3 As Xml.XmlElement
        MoveXmlArg3 = mXmlDocument.CreateElement("MOVE")
        Dim MoveXmlArg5 As Xml.XmlElement
        MoveXmlArg5 = mXmlDocument.CreateElement("MOVE")

        If arg3 = String.Empty Then
            MoveXmlArg3.SetAttribute("SOURCE", "TRANSLATE_COLLATE")
            MoveXmlArg5.SetAttribute("SOURCE", "STG(TRANSLATE_COLLATE)")
        Else
            MoveXmlArg3.SetAttribute("SOURCE", arg3)
            MoveXmlArg5.SetAttribute("SOURCE", "STG(" & arg3 & ")")
        End If
        MoveXmlArg3.SetAttribute("TARGET", "TRANSLATE_FROM")
        MoveXmlArg5.SetAttribute("TARGET", "TRANSLATE_DATALEN")

        oprlist.Add(MoveXmlArg3)
        oprlist.Add(MoveXmlArg5)


        Dim Callxml As Xml.XmlElement
        Callxml = mXmlDocument.CreateElement("CALL")
        Callxml.SetAttribute("METHOD", "TRANSLATE")
        Callxml.SetAttribute("TYPE", "Perform")
        oprlist.Add(Callxml)

        Dim MoveXmlResult As Xml.XmlElement
        MoveXmlResult = mXmlDocument.CreateElement("MOVE")
        MoveXmlResult.SetAttribute("SOURCE", "SUBSTR(TRANSLATE_RESULT,1,TRANSLATE_DATALEN)")
        MoveXmlResult.SetAttribute("TARGET", rtnExpress)
        oprlist.Add(MoveXmlResult)

        Return oprlist
    End Function
    ''' <summary>
    ''' 字符连接的处理
    ''' </summary>
    ''' <param name="strExpress"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function GetString(ByVal strExpress As String) As List(Of XmlElement)
        'MOVE语句的源头是 || 的话，改为STRING
        Dim RtnList As New List(Of XmlElement)
        Dim stringSeparators() As String = {"||"}
        Dim stringGroup As String() = strExpress.Split(stringSeparators, StringSplitOptions.None)
        Dim strwords As List(Of String) = GetSyntaxToken(strExpress)
        If stringGroup.Length > 1 Then
            Dim STRINGXml As Xml.XmlElement = mXmlDocument.CreateElement("STRING")
            STRINGXml.SetAttribute("TARGET", strwords(0))
            For Each Substr As String In stringGroup
                Dim SubStringXml As Xml.XmlElement = mXmlDocument.CreateElement("SUBSTRING")
                SubStringXml.SetAttribute("TEXT", Substr)
                STRINGXml.AppendChild(SubStringXml)
            Next
            RtnList.Add(STRINGXml)
        End If
        Return RtnList
    End Function
    ''' <summary>
    ''' 对于 -> Locator的调整
    ''' </summary>
    ''' <param name="strExpress">带有 "->" 的表达式</param>
    ''' <remarks></remarks>
    Public Shared Sub GetLocatorList(ByVal strExpress As String, ByVal PreProcess As clsStatementBlock, ByVal AfterProcess As clsStatementBlock)
        'A->B.C
        Dim strBaseAddr As String = String.Empty
        Dim strDataStru As String = String.Empty
        strBaseAddr = Mid(strExpress, 1, strExpress.IndexOf("->"))
        strDataStru = Mid(strExpress, strExpress.IndexOf("->") + 3)
        Dim strSavePointName As String = strDataStru.Split(".")(0) & "_SAVE"
        '追加一根临时指针
        Dim HasSamePoint As Boolean = False
        For Each mdata As XmlElement In mDataNode.WorkList
            If mdata.GetAttribute("NAME") = strSavePointName Then
                HasSamePoint = True
            End If
        Next
        '是否存在Point
        If HasSamePoint = False Then
            Dim TempPTRxml As XmlElement = mXmlDocument.CreateElement("SINGLEDATA")
            TempPTRxml.SetAttribute("NAME", strSavePointName)
            TempPTRxml.SetAttribute("TYPE", "PTR")
            mDataNode.WorkList.Add(TempPTRxml)
        End If

        'A->B.C=D
        Dim RtnList As New List(Of XmlElement)
        '预处理
        'SET B-PTR-SAVE TO ADDRESS OF B
        '一般的SET语句需要同时调整相同基地的变量的地址，这里应该不需要调整
        Dim SetXml As Xml.XmlElement = mXmlDocument.CreateElement("SET")
        SetXml.SetAttribute("TARGET", strSavePointName)
        SetXml.SetAttribute("SOURCE", "ADDR(" & strDataStru.Split(".")(0) & ")")
        PreProcess.AddOperation(SetXml)


        'SET ADDRESS OF B TO A
        Dim SetXml2 As Xml.XmlElement = mXmlDocument.CreateElement("SET")
        SetXml2.SetAttribute("TARGET", "ADDR(" & strDataStru.Split(".")(0) & ")")
        SetXml2.SetAttribute("SOURCE", strBaseAddr)
        PreProcess.AddOperation(SetXml2)

        '后处理
        'MOVE D TO C
        'SET ADDRESS OF B TO B-PTR-SAVE
        Dim SetXml3 As Xml.XmlElement = mXmlDocument.CreateElement("SET")
        SetXml3.SetAttribute("SOURCE", strSavePointName)
        SetXml3.SetAttribute("TARGET", "ADDR(" & strDataStru.Split(".")(0) & ")")
        AfterProcess.AddOperation(SetXml3)
    End Sub
#End Region
#Region "变量名称的改写"
    ''' <summary>
    ''' 简单的变量名称变换
    ''' </summary>
    ''' <param name="strVarName"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function ModifyVarName(ByVal strVarName As String) As String
        strVarName = strVarName.Trim
        Select Case True
            Case strVarName.StartsWith("ADDR(")
                strVarName = Mid(strVarName, 6, strVarName.Length - 6)
                strVarName = "ADDRESS  OF  " & ModifyVarName(strVarName)
            Case strVarName.StartsWith("STG(")
                strVarName = Mid(strVarName, 5, strVarName.Length - 5)
                strVarName = "LENGTH  OF  " & ModifyVarName(strVarName)
            Case strVarName.StartsWith("MOD(")
                Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strVarName)
                strVarName = "FUNCTION  MOD(" & ModifyVarName(strSubStrList(1)) & "," _
                                              & ModifyVarName(strSubStrList(2)) & ")"
            Case strVarName.StartsWith("SUBSTR(")
                Dim strSubStrList As List(Of String) = GetMethodNameAndArgs(strVarName)
                Select Case strSubStrList.Count
                    Case 4
                        'SUBSTR(Var,From,Length)
                        strVarName = ModifyVarName(strSubStrList(1)) & "(" & _
                                     ModifyVarName(strSubStrList(2)) & ":" & _
                                     ModifyVarName(strSubStrList(3)) & ")"
                    Case 3
                        'SUBSTR(Var,From)
                        strVarName = ModifyVarName(strSubStrList(1)) & "(" & _
                                     ModifyVarName(strSubStrList(2)) & ":X)"
                    Case Else
                        LogWriter.WriteLine("*ERROR:SUBSTR Format Error...")
                        LogWriter.WriteLine("*Expression:" & strVarName)
                End Select
            Case strVarName = "0"
                strVarName = "ZERO"
            Case strVarName = "' '"
                strVarName = "SPACE"
            Case Else
                If IsNumeric(strVarName) Then Return strVarName
                If strVarName.StartsWith("'") And strVarName.EndsWith("'") Then Return strVarName
                'A(1).B(2).C(3) 换为  C OF B OF A(1,2,3)
                '同时需要考虑 A.B(C.D)的情况  B OF A(D OF C)
                Dim strNewNameArray As String() = strVarName.Split(".")
                Dim NewNameRepeatArray As New List(Of String)
                If clsJustifyData.GetInitRepeat(strVarName) <> 0 Then
                    Return strVarName
                End If
                strVarName = String.Empty
                For i As Byte = 0 To strNewNameArray.Length - 1
                    If InStr(strNewNameArray(i), "(") > 0 Then
                        NewNameRepeatArray.Add(Mid(strNewNameArray(i), InStr(strNewNameArray(i), "(") + 1, strNewNameArray(i).Length - InStr(strNewNameArray(i), "(") - 1))
                        strNewNameArray(i) = Mid(strNewNameArray(i), 1, InStr(strNewNameArray(i), "(") - 1)
                    End If
                    If i = 0 Then
                        strVarName = LastModifyVarName(strNewNameArray(i).Trim)
                    Else
                        strVarName = LastModifyVarName(strNewNameArray(i).Trim) & "  OF  " & strVarName
                    End If
                Next
                If NewNameRepeatArray.Count > 0 Then
                    strVarName &= "("
                    For i As Byte = 0 To NewNameRepeatArray.Count - 1
                        If i = NewNameRepeatArray.Count - 1 Then
                            strVarName &= LastModifyVarName(NewNameRepeatArray(i))
                        Else
                            strVarName &= LastModifyVarName(NewNameRepeatArray(i)) & ","
                        End If
                    Next
                    strVarName &= ")"
                End If
        End Select
        Return strVarName
    End Function
    ''' <summary>
    ''' 变量名转换
    ''' </summary>
    ''' <param name="strVarName"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function LastModifyVarName(ByVal strVarName As String) As String
        'PL1非关键字COBOL关键字的调整
        If KeyWordList.ContainsKey(strVarName) Then
            strVarName = KeyWordList.Item(strVarName)
        End If
        '变量名的字符替换
        strVarName = strVarName.Replace("_", "-")
        strVarName = strVarName.Replace("#", "XXX")
        strVarName = strVarName.Replace("@", "AAA")
        strVarName = strVarName.Replace("\", "XXX")
        Return strVarName
    End Function
    ''' <summary>
    ''' 重置临时变量
    ''' </summary>
    ''' <remarks></remarks>
    Public Shared Sub ResetWorkData()
        Dim Work_Count As Integer = 1
        For Each WkData As XmlElement In mDataNode.WorkList
            If WkData.GetAttribute("NAME") = "WK_PLI_INIT" Then Continue For
            If WkData.GetAttribute("NAME").StartsWith("WK_PLI_I") Then
                KeyWordList.Add(WkData.GetAttribute("NAME"), "WK_PLI_I" & Work_Count)
                Work_Count += 1
            End If
        Next
    End Sub
    ''' <summary>
    ''' 改写标签名称
    ''' </summary>
    ''' <param name="OldName"></param>
    ''' <param name="IsAfter"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function ModifyLabelName(ByVal OldName As String, ByVal IsAfter As Boolean) As String
        '独立标签
        For Each SubSec As SectionNode In mProcedureNode.SectionList
            If SubSec.SectionName = OldName Then
                Return ModifySectionName(OldName, False)
            End If
        Next
        'DO...标签
        Dim strNewName As String = String.Empty
        strNewName = "YEN" & OldName
        If IsAfter Then
            strNewName &= "-AFTER"
        End If
        Return LastModifyVarName(strNewName)
    End Function
    ''' <summary>
    ''' 改写节名称
    ''' </summary>
    ''' <param name="OldName"></param>
    ''' <param name="IsAfter"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function ModifySectionName(ByVal OldName As String, ByVal IsAfter As Boolean) As String
        Dim strNewName As String = mIdentificationNode.ProgramID & "-" & LastModifyVarName(OldName)
        If IsAfter Then
            strNewName &= "-EXIT"
        End If
        Return strNewName
    End Function
    ''' <summary>
    ''' 获取函数名称和参数列表
    ''' </summary>
    ''' <param name="FunctionExpress"></param>
    ''' <returns>第一个是方法名称，第二个开始是参数</returns>
    ''' <remarks></remarks>
    Public Shared Function GetMethodNameAndArgs(ByVal FunctionExpress As String) As List(Of String)
        FunctionExpress = FunctionExpress.Trim
        Dim strList As New List(Of String)
        'Func(EX(1,2,3),PX(4,5,6),TX(7,8,9))
        'Func,EX(1,2,3),PX(4,5,6),TX(7,8,9)
        Dim FunctionName As String
        FunctionName = FunctionExpress
        If FunctionExpress.Contains("(") Then
            FunctionName = Mid(FunctionExpress, 1, InStr(FunctionExpress, "(") - 1)
            Dim ArgsExpress As String
            ArgsExpress = Mid(FunctionExpress, InStr(FunctionExpress, "(") + 1, FunctionExpress.Length - FunctionName.Length - 2)
            '通过嵌套等级为0的逗号来切开参数
            strList = GetSubLinesBySplitMark(ArgsExpress, ",", SplitStyle.NoSplitMark)
        End If
        strList.Insert(0, FunctionName)
        For i As Integer = 0 To strList.Count - 1
            '去掉多余的空白
            strList.Item(i) = strList.Item(i).Trim
        Next
        Return strList
    End Function
#End Region
End Class
